package com.zf.yichat.api.controller.user;

import com.zf.yichat.api.controller.BaseController;
import com.zf.yichat.api.dto.request.UserReportRequest;
import com.zf.yichat.model.UserReport;
import com.zf.yichat.service.UserReportService;
import com.zf.yichat.utils.response.FsResponse;
import com.zf.yichat.utils.response.FsResponseGen;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *
 */
@RestController
public class UserReportController extends BaseController {

    @Autowired
    private UserReportService userReportService;

    /**
     * 用户反馈
     */
    @PostMapping("user/report")
    public FsResponse report(@RequestBody UserReportRequest request) {
        request.valid();
        userReportService.save(request.getType(), request.getContent(), request.getId(), getUserId());
        return FsResponseGen.success();
    }
    @GetMapping("user/report")
    public FsResponse getReports(@RequestBody UserReportRequest request) {
        request.valid();
        List<UserReport> reports = userReportService.getReports();
        return FsResponseGen.successData(reports);
    }
}
